package cn.kk.librarysystem.commom;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/*
 *@author KK on 2022.10.15 17:34
 */
@Configuration
@EnableSwagger2
@EnableKnife4j
@Import(BeanValidatorPluginsConfiguration.class)
public class MyKnife4j {
    @Bean
    public Docket buildDocket(){
        ApiInfo apiInfo = new ApiInfoBuilder()
                .title("图书管理系统Api文档")
                .description("周测哈")
                .contact(new Contact("陈燕坚","http:/www.qq.com","123456.qq.com"))
                .version("版本1.1.1")
                .build();
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo)
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.kk.librarysystem.controller"))
                .build();
        return docket;
    }
}
